package com.homework;

import java.util.concurrent.FutureTask;

public class FutureTask02 {

    public static void main(String[] args) throws Exception {
        long start = System.currentTimeMillis();

        System.out.println("Main Thread Start!");

        FutureTask<String> future = new FutureTask<>(new Task(1));
        new Thread(future).start();
        if (!future.isDone()) {
            System.out.println("please wait!");
        }

        System.out.println("异步处理结果为：" + future.get());

        System.out.println("使用时间：" + (System.currentTimeMillis() - start) + " ms");

        System.out.println("Main Thread End!");
    }

}
